package mytest;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

public class demo1 {
    public static void main(String[] args) throws IOException {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("ddd.txt"));
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student("张三",23,"河北");
        Student s2 = new Student("李四",24,"北京");
        Student s3 = new Student("王五",25,"南京");
        Collections.addAll(list,s1,s2,s3);
        oos.writeObject(list);
        oos.close();
    }
}
